package com.ruoyi.web.controller.gym;

import com.ny.domain.LockerRentalDO;
import com.ny.dto.CreateGroup;
import com.ny.dto.DeleteGroup;
import com.ny.dto.LockerRentalDTO;
import com.ny.dto.RestResult;
import com.ny.dto.UpdateGroup;
import com.ny.query.LockerRentalQuery;
import com.ny.query.QueryGroup;
import com.ny.service.LockerRentalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.lang.Boolean;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 寄存租赁管理模块
 *
 * @author MSI-NB
 * @date 2025-03-08 13:14:38
 */
@Api("寄存租赁管理模块")
@RequestMapping("locker-rental")
@RestController
public class LockerRentalController {

    @Autowired
    private LockerRentalService lockerRentalService;

    /**
     * 新增寄存柜租赁记录
     *
     * @param lockerRentalDTO 寄存柜租赁记录入参对象
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation("新增寄存柜租赁记录")
    @ResponseBody
    public RestResult<Boolean> addLockerRental(@RequestBody @Validated(CreateGroup.class) LockerRentalDTO lockerRentalDTO) {
        Boolean result = lockerRentalService.addLockerRental(lockerRentalDTO);
        return RestResult.success(result);
    }

    /**
     * 取消寄存柜租赁记录
     *
     * @param lockerRentalQuery 寄存柜租赁记录查询对象
     * @return
     */
    @RequestMapping(value = "/cancel", method = RequestMethod.DELETE)
    @ApiOperation("取消寄存柜租赁记录")
    @ResponseBody
    public RestResult<Boolean> cancelLockerRental(@RequestBody @Validated(DeleteGroup.class) LockerRentalQuery lockerRentalQuery) {
        Boolean result = lockerRentalService.cancelLockerRental(lockerRentalQuery);
        return RestResult.success(result);
    }

    /**
     * 查询会员寄存柜租赁记录
     *
     * @param lockerRentalQuery 寄存柜租赁记录查询对象
     * @return
     */
    @RequestMapping(value = "/member", method = RequestMethod.GET)
    @ApiOperation("查询会员寄存柜租赁记录")
    public RestResult<List<LockerRentalDO>> getMemberLockerRentals(@Validated(QueryGroup.class) LockerRentalQuery lockerRentalQuery) {
        List<LockerRentalDO> result = lockerRentalService.getMemberLockerRentals(lockerRentalQuery);
        return RestResult.success(result);
    }

    /**
     * 查询所有寄存柜租赁记录
     *
     * @return
     */
    @RequestMapping(value = "/all", method = RequestMethod.GET)
    @ApiOperation("查询所有寄存柜租赁记录")
    public RestResult<List<LockerRentalDO>> getAllLockerRentals() {
        List<LockerRentalDO> result = lockerRentalService.getAllLockerRentals();
        return RestResult.success(result);
    }

    /**
     * 更新寄存柜租赁记录
     *
     * @param lockerRentalDTO 寄存柜租赁记录入参对象
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    @ApiOperation("更新寄存柜租赁记录")
    @ResponseBody
    public RestResult<Boolean> updateLockerRental(@RequestBody @Validated(UpdateGroup.class) LockerRentalDTO lockerRentalDTO) {
        Boolean result = lockerRentalService.updateLockerRental(lockerRentalDTO);
        return RestResult.success(result);
    }
}
